package com.ddone.rest.controller;

import com.ddone.rest.bean.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author ddone
 * @date 2024/3/22-21:44
 */
@Controller
@RequestMapping("/rest/user")
@Slf4j
public class RestUserController {

    /**
     * 查询所有用户
     * @return 查询所有用户
     * /rest/user
     */
    @GetMapping
    public String all(){
        log.warn("查询所有用户~~~~~");
        return "rest/demo";
    }

    /**
     * 按照ID查询用户
     * @param id
     * @return
     * /rest/user/id
     */
    @GetMapping("/{id}")
    public String find(@PathVariable Integer id){
        log.warn("id = " + id);
        return "rest/demo";
    }

    @GetMapping("/{username}/{password}")
    public String search(@PathVariable String username,
                         @PathVariable String password){
        log.warn("username = " + username);
        log.warn("password = " + password);
        return "rest/demo";
    }

    @PostMapping
    public String save(User user){
        log.warn("RestUserController.save");
        log.warn("user = " + user);
        return "rest/demo";
    }

    @PutMapping
    public String update(User user){
        log.warn("RestUserController.update");
        log.warn("user = " + user);
        return "rest/demo";
    }

    @DeleteMapping("/{id}")
    public String deleteById(@PathVariable String id){
        log.warn("RestUserController.deleteById");
        log.warn("id = " + id);
        return "rest/demo";
    }

    @DeleteMapping("/{username}/{password}")
    public String delete(@PathVariable String username,@PathVariable String password){
        log.warn("RestUserController.delete");
        log.warn("username = " + username);
        log.warn("password = " + password);
        return "rest/demo";
    }

}
